/**
 * 获取角色下拉数据
 *
 * @param queryParams
 */
import {AxiosPromise} from "axios";
import {RoleFormData, RoleItem, RolePageResult, RoleQueryParam} from "@/types/system/role";
import request from "@/utils/request";


export function listRole(): AxiosPromise<RoleItem[]> {
  return request({
    url: '/role/listAll',
    method: 'get',
  });
}

/**
 * 获取角色分页数据
 *
 * @param queryParams
 */
export function listRolePages(queryParams?: RoleQueryParam): AxiosPromise<RolePageResult> {
  return request({
    url: '/role/listByPage',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 获取角色详情
 *
 * @param id
 */
export function getRoleFormDetail(id: string): AxiosPromise<RoleFormData> {
  return request({
    url: '/role/details/' + id,
    method: 'get',
  });
}

/**
 * 添加角色
 *
 * @param data
 */
export function addRole(data: RoleFormData) {
  return request({
    url: '/role/add',
    method: 'post',
    data: data,
  });
}

/**
 * 编辑角色
 *
 * @param id
 * @param data
 */
export function updateRole(id: string, data: RoleFormData) {
  return request({
    url: '/role/updateById/' + id,
    method: 'put',
    data: data,
  });
}

/**
 * 批量删除角色，多个以英文逗号(,)分割
 *
 * @param id
 */
export function deleteRole(id: string) {
  return request({
    url: '/role/delete/' + id,
    method: 'delete',
  });
}
